// 把字符串两边的空格去掉
String.prototype.trim = function () {
  return this.replace(/^\s+/, "").replace(/\s+$/, "");
};

console.log("  abcd   ".trim());
